package org.uranus.consul.consumer.controller;

import com.alibaba.fastjson.JSONObject;
import com.lilanz.goods.IApiPriceTagRemote;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.uranus.consul.consumer.service.GoodsService;
import org.uranus.consul.consumer.service.JsonService;
/**
 * @date 2021/9/18
 * @auther uranus
 */
@RequestMapping("/json")
@RestController
@AllArgsConstructor
public class JsonController {
    private final JsonService jsonService;

    private final GoodsService goodsService;

    private final IApiPriceTagRemote priceTagRemote;
    @GetMapping("/user")
    public JSONObject findOne(){
        JSONObject json=new JSONObject();
        json.put("name","和三");
        json.put("age","12");
        return jsonService.findOne(json);
    }
    @GetMapping("/goods")
    public JSONObject findGodds(){
        JSONObject json=new JSONObject();
        json.put("name","和三");
        json.put("age","12");
        return (JSONObject) JSONObject.toJSON(goodsService.findGoodsPriceTag(json));
    }
    @GetMapping("/remote")
    public JSONObject findRemote(){
        JSONObject json=new JSONObject();
        json.put("name","和三");
        json.put("age","12");
        return (JSONObject) JSONObject.toJSON(priceTagRemote.findOne(json));
    }
}
